﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HashTableDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Hashtable ht = new Hashtable();
            while(true)
            {
                Console.WriteLine("请选择以下操作：");
                Console.WriteLine("1.男生     2.女生");
                Console.WriteLine("查询方式");
                Console.WriteLine("请输入你的选择:");
                string f = Console.ReadLine();
               bool genderFind;
                switch (f)
                {
                    case "1":
                        Console.WriteLine("请输入姓名：");
                        string name = Console.ReadLine();
                        Console.WriteLine("请输入性别；");
                        string gender = Console.ReadLine();
                        if (ht.ContainsKey(name))
                        {
                            Console.WriteLine("该人员不存在！","错误");
                            return;
                        }
                        ht.Add(name, gender);
                        Console.WriteLine("共有{ht.Count}人员");
                        break;
                    case "2":
                        Console.WriteLine("请输入你要查找的人员姓名：");
                        string nameFind = Console.ReadLine();
                        genderFind = (bool)ht[nameFind];
                        if(genderFind==false)
                        {
                            Console.WriteLine("该人员不存在！","错误");
                       }
                        else
                        {
                           Console.WriteLine("你所查找的人员性别是：{genderFind.ToString()}");
                        }
                        break;

                }
            }
        }
    }
}
